package com.project.common.core.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Reg {

    public static List<String> RegMatchList(String context, String reg){
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(context);
        List<String> strlist=null;
        while(matcher.find()){
            if(strlist==null){
                strlist= new ArrayList<String>();
            }
            String m=matcher.group(1);
            strlist.add(m);
            /* System.out.println(m);*/
        }
        return strlist;
    }


    public static String  RegMatch(String context,String reg){
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(context);
        while(matcher.find()){
            String m=matcher.group(1);
            /* System.out.println(m);*/
            return m;
        }
        return null;
    }
}
